package ua.kpi.transport.servlet.actions.editing;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import ua.kpi.transport.db.dao.factory.DAOFactory;
import ua.kpi.transport.db.dao.factory.DBEnum;
import ua.kpi.transport.db.dao.interfaces.IRouteDAO;
import ua.kpi.transport.db.dao.interfaces.ITransportTypeDAO;
import ua.kpi.transport.db.entities.RouteBean;
import ua.kpi.transport.db.entities.TransportTypeBean;
import ua.kpi.transport.servlet.actions.IAction;
import ua.kpi.transport.util.settings.Pages;

/**
 *
 * @author harker777   
 */
public class EditRouteAction implements IAction{

    @Override
    public String execute(HttpServletRequest request, HttpServletResponse response) 
            throws ServletException, IOException {
        IRouteDAO rd = DAOFactory.getDAOFactory(DBEnum.MYSQL).getRouteDAO();
        Integer id = Integer.valueOf(request.getParameter("id"));

        RouteBean route = rd.find(id);
        request.setAttribute("route", route);

        String page = Pages.getPage(Pages.EDIT_ROUTE_PAGE);
        return page;
    }
    
}

